package com.chen.nongansampling.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import com.chen.nongansampling.AddOperatorFragment;
import com.chen.nongansampling.MainActivity;
import com.chen.nongansampling.R;
import com.chen.nongansampling.fragment.ui.businessarchives.BusinessArchivesFragment;

public class BusinessArchivesActivity extends AppCompatActivity {
public TextView kaitou;
//用来区分跳转的是扁你页面还是添加页面 1为添加  2为编辑
public static int bianjiid=1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.business_archives_activity);
        kaitou=findViewById(R.id.kaitou);
        kaitou.setText("经营户列表");
//        if (savedInstanceState == null) {
//            getSupportFragmentManager().beginTransaction()
//                    .replace(R.id.container, BusinessArchivesFragment.newInstance())
//                    .commitNow();
//        }





        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.container, BusinessArchivesFragment.newInstance())
                    .commitNow();
        }






        Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);//隐藏标题
        toolbar.setNavigationIcon(R.mipmap.back_white);       //加载图标

        toolbar.setNavigationOnClickListener(new View.OnClickListener() {   //为图标设置监听器
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(BusinessArchivesActivity.this, MainActivity.class);
                startActivity(intent);
            }
        });

        toolbar.findViewById(R.id.add_operator).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (savedInstanceState == null) {
                    bianjiid=1;
                    kaitou.setText("经营户添加");
                    getSupportFragmentManager().beginTransaction()
                            .replace(R.id.container, AddOperatorFragment.newInstance())
                            .commitNow();
                }
            }
        });

    }
}
